package Initials;

import java.util.Hashtable;

import Market.GenCo;
import Market.LSE;
import Market.Market;

public class InitGenCo {
												/** Number of GenCos */
		private int I;
												/** GenCo's Data: {Gen ID, at Node, FCost, aT, bT, CapTL, CapTU, Initial Money in pounds} */
		private double[][] GenCoData;
												/**  GenCo's accumulative money holding, money (new) = money(previous) + DailyProfit(new) (array)*/ 
		private double[] GenCoMoney;
												/** Generators' locations {gen1 at node 1, gen2 at node3,.., geni at nodej} */
		private int[] GenCoAtNode;  
            
// Learning and action domain parameters
												/** Learning Data: {initial propensity, Cooling, Recency, Experimentation, M1, M2, M3, RIMaxL, RIMaxU, RIMinC, SlopeStart, Reward Selection} */
		private double[][] LearningData;   
												/** Cooling parameter that affects the degree to which Generator i makes use of propensity values in determining its choice probabilities  <br> @see DynTestAMES.JSLT.pdf*/
		private double Cooling;
												/** The experimentation parameter in (23) permits reinforcement to spill over to some extent from a chosen supply offer to other <br> supply offers to encourage continued experimentation with various supply offers in the early <br> stages of the learning process <br> @see DynTestAMES.JSLT.pdf (23) */  
        private double Experimentation;
												/** GenCo's Propensity */ 
        private double Propensity;
												/** Cardinality of the action domain for GenCo  <br> @see DynTestAMES.JSLT.pdf */   
        private int M1;
												/** Cardinality of the action domain for GenCo  <br> @see DynTestAMES.JSLT.pdf */ 
        private int M2;
												/** Cardinality of the action domain for GenCo  <br> @see DynTestAMES.JSLT.pdf */ 
        private int M3;
												/** Range-index parameter for Action domain construction  <br> @see DynTestAMES.JSLT.pdf */    
        private double RIMaxL;
												/** Range-index parameter for Action domain construction  <br> @see DynTestAMES.JSLT.pdf */   
        private double RIMaxU;
												/** Range-index parameter for Action domain construction  <br> @see DynTestAMES.JSLT.pdf */
        private double RIMinC;
												/** The introduction of the recency parameter in (22) acts as a damper on the growth of the propensities over time <br> @see DynTestAMES.JSLT.pdf (22) */   
        private double Recency;
												/** Slope-start parameter <br> @see DynTestAMES.JSLT.pdf (pg 33) */      
        private double slopestart;
												/** 0->profit, 1->net earnings */    
        private int RewardSelection;               
        
        double temp;

//C-O-N-S-T-R-U-C-T-O-R-----------------------------------------------------------------------	            
  public InitGenCo(Market market){
	  
	  Hashtable<String, Double> supplyOffer1  = new Hashtable<String, Double>();
	  Hashtable<String, Double> supplyOffer2  = new Hashtable<String, Double>();
	  Hashtable<String, Double> supplyOffer3  = new Hashtable<String, Double>();
	  Hashtable<String, Double> supplyOffer4  = new Hashtable<String, Double>();
	  Hashtable<String, Double> supplyOffer5  = new Hashtable<String, Double>();
	  Hashtable<String, Double> supplyOffer   = new Hashtable<String, Double>();
	  
	  Hashtable<String, Double> learningData = new Hashtable<String, Double>();
	  
	  
		 
	    //GenCoData = new double[I][8];
			  
	    for (int i=0; i<market.I; i++){				
	    	if (i == 0){
	    		
	    		supplyOffer1.put("aT",14.0);
	    		supplyOffer1.put("bT",0.005);
	    		supplyOffer1.put("capTL",0.0);
	    		supplyOffer1.put("capTU",110.0);
	    		
	    		supplyOffer = supplyOffer1;  		
	    		
	    		learningData.put("propensity", 6000.0);
	    		learningData.put("cooling", 1000.0);
	    		learningData.put("recency", 0.04);
	    		learningData.put("experimentation", 0.96);
	    		learningData.put("m1", 10.0);
	    		learningData.put("m2", 10.0);
	    		learningData.put("m3", 1.0);
	    		learningData.put("rIMaxL", 0.75);
	    		learningData.put("rIMaxU", 0.75);
	    		learningData.put("rIMinC", 1.0);
	    		learningData.put("slopeStart", 0.05);
	    		learningData.put("rewardSelection", 1.0);
	    		
			    int id = i+1;
			    int node = 1;
			    double fcost = 0.0;
			    double money = 10000.0;
			    GenCo genco = new GenCo("genco"+id, node, fcost, money, market, supplyOffer, learningData);
			    market.genCoList.put(genco.id, genco);
		  	}		  
	    	if (i == 1){
				
	    		supplyOffer2.put("aT",15.0);
	    		supplyOffer2.put("bT",0.006);
	    		supplyOffer2.put("capTL",0.0);
	    		supplyOffer2.put("capTU",100.0);
	    		
	    		supplyOffer = supplyOffer2; 
	    		
	    		learningData.put("propensity", 6000.0);
	    		learningData.put("cooling", 1000.0);
	    		learningData.put("recency", 0.04);
	    		learningData.put("experimentation", 0.96);
	    		learningData.put("m1", 10.0);
	    		learningData.put("m2", 10.0);
	    		learningData.put("m3", 1.0);
	    		learningData.put("rIMaxL", 0.75);
	    		learningData.put("rIMaxU", 0.75);
	    		learningData.put("rIMinC", 1.0);
	    		learningData.put("slopestart", 0.05);
	    		learningData.put("rewardSelection", 1.0);
	    		
			    int id = i+1;
			    int node = 1;
			    double fcost = 0.0;
			    double money = 10000.0;
			    GenCo genco = new GenCo("genco"+id, node, fcost, money, market,supplyOffer, learningData);
			    market.genCoList.put(genco.id, genco);

			}		  
	    	if (i == 2){
				
	    		supplyOffer3.put("aT",25.0);
	    		supplyOffer3.put("bT",0.001);
	    		supplyOffer3.put("capTL",0.0);
	    		supplyOffer3.put("capTU",520.0);
	    		
	    		supplyOffer = supplyOffer3; 
	    		
	    		learningData.put("propensity", 6000.0);
	    		learningData.put("cooling", 1000.0);
	    		learningData.put("recency", 0.04);
	    		learningData.put("experimentation", 0.96);
	    		learningData.put("m1", 10.0);
	    		learningData.put("m2", 10.0);
	    		learningData.put("m3", 1.0);
	    		learningData.put("rIMaxL", 0.75);
	    		learningData.put("rIMaxU", 0.75);
	    		learningData.put("rIMinC", 1.0);
	    		learningData.put("slopestart", 0.05);
	    		learningData.put("rewardSelection", 1.0);
	    		
			    int id = i+1;
			    int node = 3;
			    double fcost = 0.0;
			    double money = 10000.0;
			    GenCo genco = new GenCo("genco"+id, node, fcost, money, market,supplyOffer, learningData);
			    market.genCoList.put(genco.id, genco);

			}				  
	    	if (i == 3){
				
	    		supplyOffer4.put("aT",30.0);
	    		supplyOffer4.put("bT",0.012);
	    		supplyOffer4.put("capTL",0.0);
	    		supplyOffer4.put("capTU",200.0);
	    		
	    		supplyOffer = supplyOffer4; 
	    		
	    		learningData.put("propensity", 6000.0);
	    		learningData.put("cooling", 1000.0);
	    		learningData.put("recency", 0.04);
	    		learningData.put("experimentation", 0.96);
	    		learningData.put("m1", 10.0);
	    		learningData.put("m2", 10.0);
	    		learningData.put("m3", 1.0);
	    		learningData.put("rIMaxL", 0.75);
	    		learningData.put("rIMaxU", 0.75);
	    		learningData.put("rIMinC", 1.0);
	    		learningData.put("slopestart", 0.05);
	    		learningData.put("rewardSelection", 1.0);
	    		
			    int id = i+1;
			    int node = 4;
			    double fcost = 0.0;
			    double money = 10000.0;
			    GenCo genco = new GenCo("genco"+id, node, fcost, money, market,supplyOffer, learningData);
			    market.genCoList.put(genco.id, genco);

			}		 
	    	if (i == 4){
				
	    		supplyOffer5.put("aT",10.0);
	    		supplyOffer5.put("bT",0.07);
	    		supplyOffer5.put("capTL",0.0);
	    		supplyOffer5.put("capTU",600.0);
	    		
	    		supplyOffer = supplyOffer5; 
	    		
	    		learningData.put("propensity", 6000.0);
	    		learningData.put("cooling", 1000.0);
	    		learningData.put("recency", 0.04);
	    		learningData.put("experimentation", 0.96);
	    		learningData.put("m1", 10.0);
	    		learningData.put("m2", 10.0);
	    		learningData.put("m3", 1.0);
	    		learningData.put("rIMaxL", 0.75);
	    		learningData.put("rIMaxU", 0.75);
	    		learningData.put("rIMinC", 1.0);
	    		learningData.put("slopestart", 0.05);
	    		learningData.put("rewardSelection", 1.0);
	    		
			    int id = i+1;
			    int node = 5;
			    double fcost = 0.0;
			    double money = 10000.0;
			    GenCo genco = new GenCo("genco"+id, node, fcost, money, market,supplyOffer, learningData);
			    market.genCoList.put(genco.id, genco);

			 }		  
	    }	  
  }	
  
//-----------------------------------------------------------------------------------------------------------------------------------------
  	/** Returns GenCoData Data  */
	public double[][] getGenCoData(){		
			return GenCoData;
		}
	
//-----------------------------------------------------------------------------------------------------------------------------------------
	/** Returns Learning Data  */	
	public double[][] getLearningData() {		
			return LearningData;
		}
	
//-----------------------------------------------------------------------------------------------------------------------------------------
	/** Returns initial GenCo's money holding  */
	public double[] getGenCoMoney() {
		GenCoMoney = new double[I];
		for (int i=0;i<I;i++){
			GenCoMoney[i] = GenCoData[i][7];
		}
		return GenCoMoney;
	}
	
//-----------------------------------------------------------------------------------------------------------------------------------------
	/** Returns number of GenCos */	
	public int getNGenCo(){		
		return I;
	}
}

